import UIKit

public struct CodeBlockStyle {
    public let font: UIFont
    public let textColor: UIColor
    public let backgroundColor: UIColor
    public let cornerRadius: CGFloat
    public let borderWidth: CGFloat
    public let borderColor: UIColor?
    public let codeTextInsets: UIEdgeInsets
    public let containerInsets: UIEdgeInsets
    public let headerHeight: CGFloat
    public let headerBackgroundColor: UIColor
    public let languageLabelFont: UIFont
    public let languageLabelColor: UIColor
    public let languageLabelInsets: UIEdgeInsets
    public let copyButtonTintColor: UIColor
    public let copyButtonSize: CGSize
    public let copyButtonInsets: UIEdgeInsets
    public let expandButtonHeight: CGFloat
    public let expandButtonColor: UIColor
    public let expandButtonTextColor: UIColor
    public let expandButtonFont: UIFont
    public let expandButtonCornerRadius: CGFloat
    public let gradientMaskColors: [CGColor]
    public let gradientMaskLocations: [NSNumber]
    public let syntaxTheme: SyntaxTheme
    
    public init(
        font: UIFont = .monospacedSystemFont(ofSize: 14, weight: .regular),
        textColor: UIColor,
        backgroundColor: UIColor,
        cornerRadius: CGFloat = 8,
        borderWidth: CGFloat = 1,
        borderColor: UIColor?,
        codeTextInsets: UIEdgeInsets = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16),
        containerInsets: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),
        headerHeight: CGFloat = 44,
        headerBackgroundColor: UIColor,
        languageLabelFont: UIFont = .systemFont(ofSize: 12, weight: .medium),
        languageLabelColor: UIColor,
        languageLabelInsets: UIEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0),
        copyButtonTintColor: UIColor,
        copyButtonSize: CGSize = CGSize(width: 24, height: 24),
        copyButtonInsets: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16),
        expandButtonHeight: CGFloat = 36,
        expandButtonColor: UIColor,
        expandButtonTextColor: UIColor,
        expandButtonFont: UIFont = .systemFont(ofSize: 14, weight: .medium),
        expandButtonCornerRadius: CGFloat = 8,
        gradientMaskColors: [CGColor] = [UIColor.black.cgColor, UIColor.black.cgColor, UIColor.clear.cgColor],
        gradientMaskLocations: [NSNumber] = [0, 0.8, 1],
        syntaxTheme: SyntaxTheme
    ) {
        self.font = font
        self.textColor = textColor
        self.backgroundColor = backgroundColor
        self.cornerRadius = cornerRadius
        self.borderWidth = borderWidth
        self.borderColor = borderColor
        self.codeTextInsets = codeTextInsets
        self.containerInsets = containerInsets
        self.headerHeight = headerHeight
        self.headerBackgroundColor = headerBackgroundColor
        self.languageLabelFont = languageLabelFont
        self.languageLabelColor = languageLabelColor
        self.languageLabelInsets = languageLabelInsets
        self.copyButtonTintColor = copyButtonTintColor
        self.copyButtonSize = copyButtonSize
        self.copyButtonInsets = copyButtonInsets
        self.expandButtonHeight = expandButtonHeight
        self.expandButtonColor = expandButtonColor
        self.expandButtonTextColor = expandButtonTextColor
        self.expandButtonFont = expandButtonFont
        self.expandButtonCornerRadius = expandButtonCornerRadius
        self.gradientMaskColors = gradientMaskColors
        self.gradientMaskLocations = gradientMaskLocations
        self.syntaxTheme = syntaxTheme
    }
    
    public static let light = CodeBlockStyle(
        textColor: .black,
        backgroundColor: UIColor(hex: "#F6F8FA"),
        borderColor: UIColor(hex: "#E1E4E8"),
        headerBackgroundColor: UIColor(hex: "#F1F3F5"),
        languageLabelColor: UIColor(hex: "#666666"),
        copyButtonTintColor: UIColor(hex: "#666666"),
        expandButtonColor: UIColor(hex: "#F1F3F5"),
        expandButtonTextColor: UIColor(hex: "#0366D6"),
        syntaxTheme: .github
    )
    
    public static let dark = CodeBlockStyle(
        textColor: UIColor(hex: "#F8F8F2"),
        backgroundColor: UIColor(hex: "#282A36"),
        borderColor: UIColor(hex: "#44475A"),
        headerBackgroundColor: UIColor(hex: "#21222C"),
        languageLabelColor: UIColor(hex: "#6272A4"),
        copyButtonTintColor: UIColor(hex: "#6272A4"),
        expandButtonColor: UIColor(hex: "#21222C"),
        expandButtonTextColor: UIColor(hex: "#BD93F9"),
        syntaxTheme: .dracula
    )
    
    public static let github = CodeBlockStyle(
        textColor: UIColor(hex: "#24292E"),
        backgroundColor: UIColor(hex: "#F6F8FA"),
        borderColor: UIColor(hex: "#E1E4E8"),
        headerBackgroundColor: UIColor(hex: "#F1F3F5"),
        languageLabelColor: UIColor(hex: "#666666"),
        copyButtonTintColor: UIColor(hex: "#666666"),
        expandButtonColor: UIColor(hex: "#F1F3F5"),
        expandButtonTextColor: UIColor(hex: "#0366D6"),
        syntaxTheme: .github
    )
    
    public static let oneDark = CodeBlockStyle(
        textColor: UIColor(hex: "#ABB2BF"),
        backgroundColor: UIColor(hex: "#282C34"),
        borderColor: UIColor(hex: "#181A1F"),
        headerBackgroundColor: UIColor(hex: "#21252B"),
        languageLabelColor: UIColor(hex: "#5C6370"),
        copyButtonTintColor: UIColor(hex: "#5C6370"),
        expandButtonColor: UIColor(hex: "#21252B"),
        expandButtonTextColor: UIColor(hex: "#61AFEF"),
        syntaxTheme: .oneDark
    )
    
    public static let solarizedLight = CodeBlockStyle(
        textColor: UIColor(hex: "#657B83"),
        backgroundColor: UIColor(hex: "#FDF6E3"),
        borderColor: UIColor(hex: "#EEE8D5"),
        headerBackgroundColor: UIColor(hex: "#EEE8D5"),
        languageLabelColor: UIColor(hex: "#93A1A1"),
        copyButtonTintColor: UIColor(hex: "#93A1A1"),
        expandButtonColor: UIColor(hex: "#EEE8D5"),
        expandButtonTextColor: UIColor(hex: "#268BD2"),
        syntaxTheme: .solarizedLight
    )
    
    public static let xcode = CodeBlockStyle(
        textColor: UIColor(hex: "#000000"),
        backgroundColor: UIColor(hex: "#FFFFFF"),
        borderColor: UIColor(hex: "#E0E0E0"),
        headerBackgroundColor: UIColor(hex: "#F5F5F5"),
        languageLabelColor: UIColor(hex: "#666666"),
        copyButtonTintColor: UIColor(hex: "#666666"),
        expandButtonColor: UIColor(hex: "#F5F5F5"),
        expandButtonTextColor: UIColor(hex: "#007AFF"),
        syntaxTheme: .xcode
    )
    
    public static let dracula = CodeBlockStyle(
        textColor: UIColor(hex: "#F8F8F2"),
        backgroundColor: UIColor(hex: "#282A36"),
        borderColor: UIColor(hex: "#44475A"),
        headerBackgroundColor: UIColor(hex: "#21222C"),
        languageLabelColor: UIColor(hex: "#6272A4"),
        copyButtonTintColor: UIColor(hex: "#6272A4"),
        expandButtonColor: UIColor(hex: "#21222C"),
        expandButtonTextColor: UIColor(hex: "#BD93F9"),
        syntaxTheme: .dracula
    )
} 
